class Solution(object):
    def canReach(self, arr, start):
        n = len(arr)
        p = [0] * n

        def search(node):
            if arr[node] == 0:
                return True
            else:
                flag = False
                if node + arr[node] < n and not p[node + arr[node]]:
                    p[node + arr[node]] = 1
                    flag = search(node + arr[node])
                if flag:
                    return True
                if node - arr[node] >= 0 and not p[node - arr[node]]:
                    p[node - arr[node]] = 1
                    flag = search(node - arr[node])
                if flag:
                    return True
                else:
                    return False

        return search(start)